Y may be any array. R is a simple character array which will display identically to the display produced by Y. The result is independent of ⎕PW. If Y is a simple character array, then R is Y.
+B←⍕A←2 6⍴'HELLO PEOPLE' HELLO PEOPLE B ≡ A 1
If Y is a simple numeric scalar, then R is a vector containing the formatted number without any spaces. A floating point number is formatted according to the system variable ⎕PP. ⎕PP is ignored when formatting integers.
⎕PP←5 ⍴C←⍕⍳0 0 ⍴C←⍕10 2 C 10 ⍴C←⍕12.34 5 C 12.34 ⍕123456789 123456789 ⍕123.456789 123.46
Scaled notation is used if the magnitude of the non-integer number is too large to represent with ⎕PP significant digits or if the number requires more than five leading zeroes after the decimal point.
⍕123456.7 1.2346E5 ⍕0.0000001234 1.234E¯7
If Y is a simple numeric vector, then R is a character vector in which each element of Y is independently formatted with a single separating space between formatted elements.
⍴C←⍕¯123456 1 22.5 ¯0.000000667 5.00001 27 C ¯1.2346E5 1 22.5 ¯6.67E¯7 5
If Y is a simple numeric array rank higher than one, R is a character array with the same shape as Y except that the last dimension of Y is determined by the length of the formatted data. The format width is determined independently for each column of Y, such that:
C←22 ¯0.000000123 2.34 ¯212 123456 6.00002 0 ⍴C←⍕2 2 3⍴C 2 2 29 C 22 ¯1.2300E¯7 2.3400E0 ¯212 1.2346E5 6.0000E0 0 2.2000E1 ¯1.2300E¯7 2.34 ¯2.1200E2 1.2346E5
If Y is non-simple, and all items of Y at any depth are scalars or vectors, then R is a vector.
B←⍕A←'ABC' 100 (1 2 (3 4 5)) 10 ⍴A 4 ≡A ¯3 ⍴B 26 ≡B 1 A ABC 100 1 2 3 4 5 10 B ABC 100 1 2 3 4 5 10
By replacing spaces with ^, it is clearer to see how the result of ⍕ is formed:
^ABC^^100^^1^2^^3^4^5^^^10
If Y is non-simple, and all items of Y at any depth are not scalars, then R is a matrix.
D←⍕C←1 'AB' (2 2⍴1+⍳4) (2 2 3⍴'CDEFGHIJKLMN') C 1 AB 2 3 CDE 4 5 FGH IJK LMN ⍴C 4 ≡C ¯2 D 1 AB 2 3 CDE 4 5 FGH IJK LMN ⍴D 5 16 ≡D 1
By replacing spaces with ^, it is clearer to see how the result of ⍕ is formed:
1^^AB^^2^3^^CDE^ ^^^^^^^4^5^^FGH^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^IJK^ ^^^^^^^^^^^^LMN^
⎕PP is an implicit argument of Monadic Format.